<template>
	<view class="safe_area">
		<view class="message_details">
			<scroll-view scroll-y="true" style="height: 99vh;">
				<view class="message_details_title">{{info?.title}}</view>
				<view class="message_details_subtitle">
					<text>{{info?.pushTime}}</text>
					<text v-if="info?.activityId" @click="handleAcitvityDetails">点击跳转活动详情</text>
				</view>
				<rich-text :nodes="handleFormat(info?.content)" preview></rich-text>
				<view style="height: 20px;"></view>
			</scroll-view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { handleFormat } from '@/util/index';
	import { ref } from 'vue';
	import { qxNoticeAnnoQueryById } from '@/config/mine.api';
	import { queryIsMedia } from '@/config/index.api';
	import { onLoad } from "@dcloudio/uni-app";

	const info = ref();

	onLoad(async (params) => {
		const res = await qxNoticeAnnoQueryById({ id: params?.id });
		info.value = res;
		console.log(res, 'er');
	})

	/**
	 * 跳转活动详情
	 */
	async function handleAcitvityDetails() {
		const activityId = info.value?.activityId;
		const data = await queryIsMedia({ id: activityId });
		if (data == '1') {
			uni.$u.route('/pages/index/acitvityImgVideoDetails', {
				id: activityId
			});
		} else {
			uni.$u.route('/pages/index/acitvityDetails', {
				id: activityId
			});
		}
	}
</script>

<style lang="scss" scoped>
	.safe_area {
		background-color: #ffffff;

		.message_details {
			padding: 20rpx 40rpx;
			background-color: #ffffff;

			.message_details_title {
				font-size: 36rpx;
				font-weight: 500;
				line-height: 50rpx;
				word-wrap: break-word;
			}

			.message_details_subtitle {
				margin-top: 12rpx;
				margin-bottom: 14rpx;
				color: #999999;
				font-size: 28rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				&>text {
					flex: 1;

					&:nth-child(2) {
						color: #2F318B;
						text-align: right;
						font-size: 500;
					}
				}
			}

			rich-text {
				word-wrap: break-word;
			}
		}

	}
</style>